package yhao.infra.feature.aliyun.oss;

import com.aliyun.oss.ClientBuilderConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author yoara
 * <p> Created on 2019/9/12 </p>
 */
@ConfigurationProperties(prefix = "yhao.feature.aliyun.oss")
public class AliyunOssProperties {
    /** 图片尺寸限制，单位为k，默认10240 **/
    private int imgSize = 10240;

    /** 文件尺寸限制，单位为k，默认10240 **/
    private int fileSize = 10240;
    /**请求的accessKey**/
    private String accessKey;

    /**请求的secretKey**/
    private String secretKey;

    /**资源同protect使用和一般资源一样的配置**/
    private boolean protectUseFileProperties;

    /**保护资源的bucket**/
    private Bucket protect = new Bucket();

    /**一般资源的bucket**/
    private Bucket file = new Bucket();

    public int getImgSize() {
        return imgSize;
    }

    public void setImgSize(int imgSize) {
        this.imgSize = imgSize;
    }

    public int getFileSize() {
        return fileSize;
    }

    public void setFileSize(int fileSize) {
        this.fileSize = fileSize;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public Bucket getProtect() {
        return protect;
    }

    public void setProtect(Bucket protect) {
        this.protect = protect;
    }

    public Bucket getFile() {
        return file;
    }

    public void setFile(Bucket file) {
        this.file = file;
    }

    public boolean isProtectUseFileProperties() {
        return protectUseFileProperties;
    }

    public void setProtectUseFileProperties(boolean protectUseFileProperties) {
        this.protectUseFileProperties = protectUseFileProperties;
    }

    /**
     * @see <a href="https://help.aliyun.com/document_detail/31837.html?spm=a2c4g.11186623.2.9.2d842841PxqQgT#concept-zt4-cvy-5db">同地址参考</a>
     * **/
    public static class Bucket{
        /**bucket地址**/
        private String url;
        /**bucket名**/
        private String name;
        /**endpoint**/
        private String endpoint;

        /**文件的路径（前缀）**/
        private String prefix;

        /**可配置的参数，选填**/
        private ClientBuilderConfiguration clientConf = new ClientBuilderConfiguration();

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getPrefix() {
            return prefix;
        }

        public void setPrefix(String prefix) {
            this.prefix = prefix;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getEndpoint() {
            return endpoint;
        }

        public void setEndpoint(String endpoint) {
            this.endpoint = endpoint;
        }

        public ClientBuilderConfiguration getClientConf() {
            return clientConf;
        }

        public void setClientConf(ClientBuilderConfiguration clientConf) {
            this.clientConf = clientConf;
        }
    }
}
